:root {
  --primary-color: #6b73ff;
  --primary-dark-color: #4d56d8;
  --selection-color: #3498db;
  --danger-color: #e74c3c;
  --danger-dark-color: #c0392b;
  --dark-text: #2c3e50;
  --bg-light: #f5f7fa;
  --bg-white: #ffffff;
  --border-color-default: #000000;
}

* {
  margin: 0;
  padding: 0;
  box-sizing: border-box;
}
body {
  background-color: var(--bg-light);
  padding: 20px;
  user-select: none;
  -webkit-user-drag: none;
  overflow: hidden;
}
.container {
  width: 100%;
  height: calc(100vh - 40px);
  display: flex;
  flex-direction: column;
}
.header {
  text-align: center;
  margin-bottom: 20px;
}
.drop-container {
  flex: 1;
  width: 100%;
  background: var(--bg-white);
  border-radius: 8px;
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.1);
  position: relative;
  overflow: hidden;
}
.drop-container.drawing-arrow {
  cursor: crosshair;
}

.element {
  position: absolute;
  border: 2px solid transparent;
  cursor: move;
  z-index: 10;
  min-width: 50px;
  min-height: 50px;
  display: flex;
  align-items: center;
  justify-content: center;
}
.element.selected {
  border-color: var(--selection-color);
  z-index: 15;
}
.element.dragging {
  opacity: 0.8;
  z-index: 20;
}

.element-shape {
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  background-color: var(--border-color-default);
}
.element-content {
  position: absolute;
  top: 1px;
  left: 1px;
  width: calc(100% - 2px);
  height: calc(100% - 2px);
  background-color: var(--bg-white);
  z-index: 2;
  padding: 10px;
  overflow: hidden;
  outline: none;
  display: flex;
  align-items: center;
  justify-content: center;
  text-align: center;
}

.element.circle .element-shape,
.element.circle .element-content {
  border-radius: 50%;
}
.element.triangle .element-shape,
.element.triangle .element-content {
  clip-path: polygon(50% 0%, 0% 100%, 100% 100%);
}
.element.triangle .element-content {
  padding-top: 25%;
  align-items: flex-start;
}

.remove-element-btn,
.resize-handle {
  display: none;
}
.element.selected .remove-element-btn,
.element.selected .resize-handle {
  display: flex;
}
.remove-element-btn {
  position: absolute;
  top: -10px;
  right: -10px;
  width: 20px;
  height: 20px;
  background: var(--danger-color);
  color: white;
  border: 1px solid white;
  border-radius: 50%;
  cursor: pointer;
  align-items: center;
  justify-content: center;
  font-size: 14px;
  font-weight: bold;
  z-index: 25;
}
.resize-handle {
  position: absolute;
  width: 10px;
  height: 10px;
  background: var(--selection-color);
  border: 1px solid white;
  border-radius: 50%;
  z-index: 20;
}
.resize-handle.br {
  bottom: -6px;
  right: -6px;
  cursor: se-resize;
}
.resize-handle.bl {
  bottom: -6px;
  left: -6px;
  cursor: sw-resize;
}
.resize-handle.tr {
  top: -6px;
  right: -6px;
  cursor: ne-resize;
}
.resize-handle.tl {
  top: -6px;
  left: -6px;
  cursor: nw-resize;
}

.arrow-line {
  position: absolute;
  height: 2px;
  background: #333;
  transform-origin: left center;
  pointer-events: none;
  z-index: 5;
}
.arrow-head {
  position: absolute;
  width: 0;
  height: 0;
  border-style: solid;
  pointer-events: none;
  z-index: 5;
}
.arrow-head.single {
  border-width: 6px 0 6px 10px;
  border-color: transparent transparent transparent #333;
}
.arrow-head.double {
  border-width: 6px 10px 6px 0;
  border-color: transparent #333 transparent transparent;
}
.toolbar {
  display: flex;
  justify-content: center;
  margin-bottom: 15px;
  gap: 10px;
  flex-wrap: wrap;
}
.tool-btn {
  padding: 8px 15px;
  background: var(--primary-color);
  color: white;
  border: none;
  border-radius: 4px;
  cursor: pointer;
  font-size: 14px;
  transition: all 0.3s;
}
.tool-btn.active {
  background: #3a43c4;
  box-shadow: inset 0 2px 5px rgba(0, 0, 0, 0.2);
  transform: translateY(0);
}
.tool-btn:hover {
  background: var(--primary-dark-color);
  transform: translateY(-2px);
}
.tool-btn.danger {
  background: var(--danger-color);
}
.tool-btn.danger:hover {
  background: var(--danger-dark-color);
}
.panel {
  display: none;
  position: absolute;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
  background: white;
  padding: 25px;
  border-radius: 8px;
  box-shadow: 0 5px 25px rgba(0, 0, 0, 0.2);
  z-index: 100;
  width: 90%;
  max-width: 600px;
}
.overlay {
  display: none;
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  background: rgba(0, 0, 0, 0.5);
  z-index: 99;
}
.panel-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 20px;
}
.panel-header h2,
.panel-header h4 {
  color: var(--dark-text);
  margin: 0;
}
.close-btn {
  background: none;
  border: none;
  font-size: 24px;
  cursor: pointer;
  color: var(--light-text);
}
.panel-actions {
  display: flex;
  justify-content: flex-end;
  gap: 10px;
  margin-top: 20px;
}
.library-section h3 {
  margin-top: 20px;
  margin-bottom: 10px;
  border-bottom: 1px solid #e0e0e0;
  padding-bottom: 5px;
}
.library-section:first-child h3 {
  margin-top: 0;
}
.library-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(120px, 1fr));
  gap: 15px;
}
.library-item {
  border: 1px solid #ddd;
  border-radius: 4px;
  padding: 10px;
  text-align: center;
  cursor: pointer;
  transition: all 0.2s;
  position: relative;
  padding-bottom: 30px;
}
.library-item:hover {
  border-color: var(--primary-color);
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.1);
}
.library-preview {
  position: relative;
  width: 80px;
  height: 50px;
  margin: 0 auto 10px;
}
.library-preview-shape {
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  background-color: var(--border-color-default);
}
.library-preview-content {
  position: absolute;
  top: 1px;
  left: 1px;
  width: calc(100% - 2px);
  height: calc(100% - 2px);
  background-color: var(--bg-white);
}
.library-item.circle .library-preview-shape,
.library-item.circle .library-preview-content {
  border-radius: 50%;
}
.library-item.triangle .library-preview-shape,
.library-item.triangle .library-preview-content {
  clip-path: polygon(50% 0%, 0% 100%, 100% 100%);
}
.library-item .item-name {
  color: var(--dark-text);
  font-size: 14px;
  position: absolute;
  bottom: 10px;
  width: 100%;
  left: 0;
}
.form-group {
  margin-bottom: 15px;
}
.form-group label {
  display: block;
  margin-bottom: 5px;
  font-weight: bold;
  color: var(--dark-text);
}
.form-group input,
.form-group textarea {
  width: 100%;
  padding: 8px;
  border: 1px solid #e0e0e0;
  border-radius: 4px;
}
.prop-item {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 10px;
}
.io-panel-content {
  display: flex;
  flex-direction: column;
  gap: 25px;
}
.storage-options fieldset {
  border: 1px solid #e0e0e0;
  border-radius: 4px;
  padding: 15px;
}
.storage-options legend {
  font-weight: bold;
  padding: 0 5px;
}
.storage-options label {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  margin-right: 15px;
}
.io-actions {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(140px, 1fr));
  gap: 15px;
}
